<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<ui:composition >
<div align="center">
		<h:form id="search">

			<h:panelGrid id="search" columns="4" align="center">
				<h:outputLabel value="Tytuł" for="title" />
				<h:inputText id="title" value="#{searchBean.bookToSearch.title}"
					immediate="true" />

				<h:outputLabel value="Autor" for="author" />
				<h:inputText id="author" value="#{searchBean.bookToSearch.author}"
					immediate="true" />

				<h:outputLabel value="Wydawnictwo" for="publisher" />
				<h:inputText id="publisher"
					value="#{searchBean.bookToSearch.publisher}" immediate="true" />

				<h:outputLabel value="Rok wydania" for="publicationYear" />
				<h:inputText id="publicationYear"
					value="#{searchBean.bookToSearch.publicationYear}" immediate="true" />

				<h:outputLabel value="Kategorie" for="category" />
				<h:selectOneMenu id="category" immediate="true" value="#{searchBean.bookToSearch.categories}">
				
					<f:selectItems value="#{userBean.bookCategories}" />
				</h:selectOneMenu>

				<h:commandButton value="Szukaj" action="#{searchBean.searchAllBooks}"/>

			</h:panelGrid>


			<h:messages globalOnly="true" layout="table" />


			<h:panelGroup id="result">
				<h:dataTable value="#{searchBean.results}" var="book"
					bgcolor="#F1F1F1" border="2" width="90%">
					<h:column>
						<f:facet name="header">Tytuł </f:facet>
						<h:outputText value="#{book.title}" />
					</h:column>

					<h:column>
						<f:facet name="header">Autor</f:facet>
						<h:outputText value="#{book.author}" />
					</h:column>

					<h:column>
						<f:facet name="header">Wydawnictwo </f:facet>
						<h:outputText value="#{book.publisher}" />
					</h:column>

					<h:column>
						<f:facet name="header">Rok </f:facet>
						<h:outputText value="#{book.publicationYear}" />
					</h:column>

					<h:column>
						<f:facet name="header">Kategorie </f:facet>
						<h:outputText value="#{book.categories}" />
					</h:column>
	

					<h:column>
						<f:facet name="header"></f:facet>

					<h:commandButton value="Dodaj" action="#{searchBean.redirect}">
						<f:setPropertyActionListener target="#{searchBean.selectedBook}" value="#{book}"/>
					</h:commandButton>

					</h:column>

				</h:dataTable>
			</h:panelGroup>
			
		</h:form>
		</div>
</ui:composition>

</html>